Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@oada/types

Package Overview
Dependencies
Maintainers
8
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oada/types

TypeScript type definitions for OADA formats

  • 3.5.3
  • Source
  • npm
  • Socket score

Version published
Maintainers
8
Created
Source

@OADA/types

This package is TypeScript type definitions for known OADA formats. These types are based on OADA/formats.

Installation

yarn add @oada/types

Usage

The type definition for a given format can be imported based on its $id. For example, the OADA Bookmarks v1 format can be imported like so:

/**
 * Import the type definition for
 * {@link https://formats.openag.io/oada/bookmarks/v1.schema.json}
 */
import Bookmarks from '@oada/types/oada/bookmarks/v1';

Runtime Validation

Since the formats are backed by schemas, it is possible to check data against a format at runtime. All the types in this package export methods for doing so which are typed properly for TypeScript to understand their type implications.

/**
 * Every type also exports both @method is and @method assert
 */
import Bookmarks, {is, assert} from '@oada/types/oada/bookmarks/v1'

const data1: any = /* Some data */

// True if data matches type Bookmarks, false if not
if (is(data1)) {
  // TS understands data is a bookmarks here
  const bookmarks: Bookmarks = data1
}

const data2: any = /* Some data */

// Throws if data is not of type Bookmarks
assert(data2)
// TS understands data is a bookmarks here
const bookmarks: Bookmarks = data2

Keywords

FAQs

Package last updated on 02 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc